import 'package:flutter/widgets.dart';

class CoreTranslation {
  static final delegate = _CoreTranslationDelegate();

  static CoreTranslation of(BuildContext context) {
    return Localizations.of(context, CoreTranslation);
  }

  late String _languageCode;

  Future<void> load(Locale locale) async {
    _languageCode = locale.languageCode;
  }

  String _resolve(Map<String, String> translations) {
    return translations[_languageCode]!;
  }

  String get headerSigningInButtonTitle {
    return _resolve(const {
      'ru': 'Войти',
    });
  }

  String get headerSigningUpButtonTitle {
    return _resolve(const {
      'ru': 'Создать аккаунт',
    });
  }

  String get headerAngryWordsProRegularButtonTitle {
    return _resolve(const {
      'ru': 'Angry Words Pro',
    });
  }

  String get headerAngryWordsProCompactButtonTitle {
    return _resolve(const {
      'ru': 'PRO',
    });
  }

  String get headerUserActionDialogAccountActionTileTitle {
    return _resolve(const {
      'ru': 'Аккаунт',
    });
  }

  String get headerUserActionDialogSigningOutActionTileTitle {
    return _resolve(const {
      'ru': 'Выйти',
    });
  }

  String get headerUserActionDialogSigningInActionTileTitle {
    return _resolve(const {
      'ru': 'Войти',
    });
  }

  String get headerUserActionDialogSigningUpActionTileTitle {
    return _resolve(const {
      'ru': 'Создать аккаунт',
    });
  }
}

class _CoreTranslationDelegate extends LocalizationsDelegate<CoreTranslation> {
  @override
  bool isSupported(Locale locale) => const ['ru'].contains(locale.languageCode);

  @override
  bool shouldReload(LocalizationsDelegate<CoreTranslation> old) => false;

  @override
  Future<CoreTranslation> load(Locale locale) async {
    final translation = CoreTranslation();
    await translation.load(locale);
    return translation;
  }
}
